/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * TelaResultado.java
 *
 * Created on 26/05/2010, 14:05:26
 */
package visao;

import java.awt.Color;
import java.awt.Component;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import jxl.write.Number;

/**
 *
 * @author Hemerson
 */
public class TelaResultado extends javax.swing.JInternalFrame {

    DefaultTableCellRenderer cellRenderer = new DefaultTableCellRenderer();
    //DefaultTableModel modeloTabelaResultadosSessao;
    TelaSemivariograma telaSemivariograma;
    TelaAG telaAG;

    /** Creates new form TelaResultado */
    public TelaResultado() {
        initComponents();
        jTextFieldResultadoAlcance.setBackground(Color.WHITE);
        jTextFieldResultadoContribuicao.setBackground(Color.WHITE);
        jTextFieldResultadoEfeitoPepita.setBackground(Color.WHITE);
        jTextFieldResultadoFitness.setBackground(Color.WHITE);

        jTableResultados.getTableHeader().setReorderingAllowed(false);
        jTableResultadosSessao.getTableHeader().setReorderingAllowed(false);
        cellRenderer.setHorizontalAlignment(SwingConstants.CENTER);
        jTableResultados.getColumnModel().getColumn(0).setPreferredWidth(80);
        jTableResultados.getColumnModel().getColumn(1).setPreferredWidth(80);
        jTableResultados.getColumnModel().getColumn(2).setPreferredWidth(80);
        jTableResultados.getColumnModel().getColumn(3).setPreferredWidth(160);
        jTableResultados.getColumnModel().getColumn(0).setCellRenderer(cellRenderer);
        jTableResultados.getColumnModel().getColumn(1).setCellRenderer(cellRenderer);
        jTableResultados.getColumnModel().getColumn(2).setCellRenderer(cellRenderer);
        jTableResultados.getColumnModel().getColumn(3).setCellRenderer(cellRenderer);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel2 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane7 = new javax.swing.JScrollPane();
        jTableResultados = new javax.swing.JTable();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextAreaResultado = new javax.swing.JTextArea();
        jPanel7 = new javax.swing.JPanel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jTextFieldResultadoAlcance = new javax.swing.JTextField();
        jTextFieldResultadoEfeitoPepita = new javax.swing.JTextField();
        jTextFieldResultadoContribuicao = new javax.swing.JTextField();
        jButtonVerResultado = new javax.swing.JButton();
        jTextFieldResultadoFitness = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        jButtonVoltarTelaAG = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTableResultadosSessao = new javax.swing.JTable();
        jButtonSalvarTabela = new javax.swing.JButton();

        setClosable(true);
        setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE);
        setTitle("Software SEMAG v1.0 - Resultado");

        jPanel4.setBackground(new java.awt.Color(255, 255, 255));

        jTableResultados.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Alcance", "Efeito Pepita", "Contribuição", "Fitness"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTableResultados.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        jTableResultados.setShowVerticalLines(false);
        jTableResultados.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTableResultadosMouseClicked(evt);
            }
        });
        jScrollPane7.setViewportView(jTableResultados);

        jTextAreaResultado.setColumns(20);
        jTextAreaResultado.setEditable(false);
        jTextAreaResultado.setFont(new java.awt.Font("Tahoma", 0, 13)); // NOI18N
        jTextAreaResultado.setRows(5);
        jScrollPane1.setViewportView(jTextAreaResultado);

        jPanel7.setBackground(new java.awt.Color(255, 255, 255));
        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Melhor Resultado", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 0, 255))); // NOI18N

        jLabel14.setText("A:");

        jLabel15.setText("C0:");

        jLabel16.setText("C1:");

        jTextFieldResultadoAlcance.setEditable(false);
        jTextFieldResultadoAlcance.setHorizontalAlignment(javax.swing.JTextField.CENTER);

        jTextFieldResultadoEfeitoPepita.setEditable(false);
        jTextFieldResultadoEfeitoPepita.setHorizontalAlignment(javax.swing.JTextField.CENTER);

        jTextFieldResultadoContribuicao.setEditable(false);
        jTextFieldResultadoContribuicao.setHorizontalAlignment(javax.swing.JTextField.CENTER);

        jButtonVerResultado.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/verResultado.png"))); // NOI18N
        jButtonVerResultado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonVerResultadoActionPerformed(evt);
            }
        });

        jTextFieldResultadoFitness.setHorizontalAlignment(javax.swing.JTextField.CENTER);

        jLabel17.setText("F:");

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addComponent(jLabel14)
                        .addGap(10, 10, 10)
                        .addComponent(jTextFieldResultadoAlcance, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(jPanel7Layout.createSequentialGroup()
                            .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(jLabel17, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jLabel16, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addGroup(jPanel7Layout.createSequentialGroup()
                                    .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addComponent(jTextFieldResultadoEfeitoPepita, javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jTextFieldResultadoContribuicao, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 101, Short.MAX_VALUE))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jButtonVerResultado, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(jTextFieldResultadoFitness))
                            .addGap(38, 38, 38))
                        .addComponent(jLabel15, javax.swing.GroupLayout.Alignment.LEADING)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel14)
                            .addComponent(jTextFieldResultadoAlcance, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel15)
                            .addComponent(jTextFieldResultadoEfeitoPepita, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel16)
                            .addComponent(jTextFieldResultadoContribuicao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jButtonVerResultado, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel17)
                    .addComponent(jTextFieldResultadoFitness, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jButtonVoltarTelaAG.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/voltar.png"))); // NOI18N
        jButtonVoltarTelaAG.setToolTipText("Retorna para as configurações do AG");
        jButtonVoltarTelaAG.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonVoltarTelaAGActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 420, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGap(37, 37, 37)
                        .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, 204, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jButtonVoltarTelaAG, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 276, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 276, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(6, 6, 6)
                        .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 22, Short.MAX_VALUE)
                        .addComponent(jButtonVoltarTelaAG, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 480, Short.MAX_VALUE))
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab("Resultados", jPanel2);

        jTableResultadosSessao.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "", "Estimador", "Modelo", "Cruzamento", "Mutação", "Tempo (ms)", "Eficiência"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTableResultadosSessao.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        jTableResultadosSessao.setCellSelectionEnabled(true);
        jScrollPane2.setViewportView(jTableResultadosSessao);

        jButtonSalvarTabela.setText("Salvar Tabela");
        jButtonSalvarTabela.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSalvarTabelaActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 702, Short.MAX_VALUE)
                    .addComponent(jButtonSalvarTabela))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 439, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButtonSalvarTabela)
                .addContainerGap(23, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Resultados Sessão", jPanel3);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 727, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 530, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonVoltarTelaAGActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonVoltarTelaAGActionPerformed
        this.setVisible(false);
        Component content = this.getContentPane();
        int x = (content.getWidth() - telaAG.getWidth()) / 2;
        int y = (content.getHeight() - telaAG.getHeight()) / 2;
        telaAG.setLocation(x, y);
        telaAG.getJProgressBarAG().setStringPainted(false);
        telaAG.getJProgressBarAG().setValue(0);
        telaAG.setVisible(true);
}//GEN-LAST:event_jButtonVoltarTelaAGActionPerformed

    private void jButtonVerResultadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonVerResultadoActionPerformed
        telaSemivariograma.getJSliderAlcance().setValue(Integer.parseInt(jTextFieldResultadoAlcance.getText()));
        telaSemivariograma.getJSliderEfeitoPepita().setValue((int) (Double.parseDouble(jTextFieldResultadoEfeitoPepita.getText()) * 10000));
        telaSemivariograma.getJSliderContribuicao().setValue((int) (Double.parseDouble(jTextFieldResultadoContribuicao.getText()) * 10000));

        if (telaSemivariograma.isVisible()) {
            telaSemivariograma.setVisible(false);
        }
        telaSemivariograma.setVisible(true);
}//GEN-LAST:event_jButtonVerResultadoActionPerformed

    private void jTableResultadosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableResultadosMouseClicked
        if (evt.getClickCount() == 2) {
            this.mostraResultado();
        }
}//GEN-LAST:event_jTableResultadosMouseClicked

    private void jButtonSalvarTabelaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSalvarTabelaActionPerformed
        JFileChooser fc = new JFileChooser();
        fc.setDialogTitle("Escolha o local para salvar a tabela");
        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // restringe a amostra a diretorios apenas
        fc.setFileFilter(new FileNameExtensionFilter("Planilha do Microsoft Excel", "xls"));
        fc.setCurrentDirectory(new File("arquivos/"));
        int res = fc.showOpenDialog(null);

        if (res == JFileChooser.APPROVE_OPTION) {
            File arquivo = fc.getSelectedFile();
            String dir = arquivo.getAbsolutePath();
            dir = dir.replace("\\", "/");
            try {
                WritableWorkbook workbook = Workbook.createWorkbook(new File(dir + ".xls"));
                WritableSheet sheet = workbook.createSheet("Resultado", 0);
                DefaultTableModel modelo = (DefaultTableModel) jTableResultadosSessao.getModel();

                Label label = new Label(0, 0, "");
                sheet.addCell(label);
                label = new Label(1, 0, "Estimador");
                sheet.addCell(label);
                label = new Label(2, 0, "Modelo");
                sheet.addCell(label);
                label = new Label(3, 0, "Cruzamento");
                sheet.addCell(label);
                label = new Label(4, 0, "Mutação");
                sheet.addCell(label);
                label = new Label(5, 0, "Tempo (ms)");
                sheet.addCell(label);
                label = new Label(6, 0, "Eficiência");
                sheet.addCell(label);

                for (int i = 0; i < modelo.getRowCount(); i++) {
                    for (int j = 0; j < modelo.getColumnCount(); j++) {
                        if ((j == 0) || (j == 5)) {
                            int valor = Integer.parseInt("" + modelo.getValueAt(i, j));
                            Number n = new Number(j, i + 1, valor);
                            sheet.addCell(n);
                        } else {
                            label = new Label(j, i + 1, "" + modelo.getValueAt(i, j));
                            sheet.addCell(label);
                        }
                    }
                }
                workbook.write();
                workbook.close();
                JOptionPane.showMessageDialog(null, "Tabela salva com sucesso!", dir, JOptionPane.INFORMATION_MESSAGE);
            } catch (WriteException ex) {
                Logger.getLogger(TelaResultado.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(TelaResultado.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else { //nao selecionou nenhum diretorio
        }
    }//GEN-LAST:event_jButtonSalvarTabelaActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonSalvarTabela;
    private javax.swing.JButton jButtonVerResultado;
    private javax.swing.JButton jButtonVoltarTelaAG;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTableResultados;
    private javax.swing.JTable jTableResultadosSessao;
    private javax.swing.JTextArea jTextAreaResultado;
    private javax.swing.JTextField jTextFieldResultadoAlcance;
    private javax.swing.JTextField jTextFieldResultadoContribuicao;
    private javax.swing.JTextField jTextFieldResultadoEfeitoPepita;
    private javax.swing.JTextField jTextFieldResultadoFitness;
    // End of variables declaration//GEN-END:variables

    private void mostraResultado() {
        int linha = jTableResultados.getSelectedRow();
        if (linha >= 0) {
            int a = new Integer("" + jTableResultados.getValueAt(linha, 0));
            double c0 = Double.parseDouble("" + jTableResultados.getValueAt(linha, 1));
            double c1 = Double.parseDouble("" + jTableResultados.getValueAt(linha, 2));
            telaSemivariograma.getJTextFieldAlcance().setText("" + a);
            telaSemivariograma.getJTextFieldEfeitoPepita().setText("" + c0);
            telaSemivariograma.getJTextFieldContribuicao().setText("" + c1);
            telaSemivariograma.getJSliderAlcance().setValue(a);
            telaSemivariograma.getJSliderEfeitoPepita().setValue((int) (c0 * 10000));
            telaSemivariograma.getJSliderContribuicao().setValue((int) (c1 * 10000));
            if (telaSemivariograma.isVisible()) {
                telaSemivariograma.setVisible(false);
            }
            telaSemivariograma.setVisible(true);
        }
    }

    public JTable getJTableResultado() {
        return this.jTableResultados;
    }

    public JTable getJTableResultadosSessao() {
        return this.jTableResultadosSessao;
    }

    public JTextField getJTextFieldResultadoAlcance() {
        return this.jTextFieldResultadoAlcance;
    }

    public JTextField getJTextFieldResultadoEfeitoPepita() {
        return this.jTextFieldResultadoEfeitoPepita;
    }

    public JTextField getJTextFieldResultadoContribuicao() {
        return this.jTextFieldResultadoContribuicao;
    }

    public JTextField getJTextFieldResultadoFitness() {
        return this.jTextFieldResultadoFitness;
    }

    public JTextArea getJTextAreaResultado() {
        return this.jTextAreaResultado;
    }

    public JTabbedPane getJTabbedPane() {
        return this.jTabbedPane1;
    }

    public void setTelaAG(TelaAG telaAG) {
        this.telaAG = telaAG;
    }

    public void setTelaSemivariograma(TelaSemivariograma telaSemivariograma) {
        this.telaSemivariograma = telaSemivariograma;
    }

    public DefaultTableModel getModeloTabelaResultadosSessao() {
        return (DefaultTableModel) this.jTableResultadosSessao.getModel();
    }

    public void arrumaTabelaResultadosSessao() {
        jTableResultadosSessao.getColumnModel().getColumn(0).setPreferredWidth(50);
        jTableResultadosSessao.getColumnModel().getColumn(1).setPreferredWidth(100);
        jTableResultadosSessao.getColumnModel().getColumn(2).setPreferredWidth(100);
        jTableResultadosSessao.getColumnModel().getColumn(3).setPreferredWidth(100);
        jTableResultadosSessao.getColumnModel().getColumn(4).setPreferredWidth(100);
        jTableResultadosSessao.getColumnModel().getColumn(5).setPreferredWidth(80);
        jTableResultadosSessao.getColumnModel().getColumn(6).setPreferredWidth(160);
        for (int i = 0; i < jTableResultadosSessao.getColumnCount(); i++) {
            jTableResultadosSessao.getColumnModel().getColumn(i).setCellRenderer(cellRenderer);
        }
    }
}
